package test;

import org.junit.Test;

import sqlengine.Main;

public class DropTable {

	static int score = 0;
	
	@Test
	public void drop(){
		boolean eCaught = false;
		String query = "drop table abc;\n";
		String out = null;
		try{
			Main m = new Main();
			out = m.process(query);			
		}catch(Exception e){
			eCaught = true;
		}
		
		if(out != null && out.equals("Error\n")){
			score+= Breakdown.drop;
			SC.score.append("\n\t dropTable checks if table already exists - " + Breakdown.drop + "/" + Breakdown.drop);
		}else{
			SC.score.append("\n\t dropTable doesn't check if table already exists - 0/" + Breakdown.drop);
		}	
	}
	
	
	@Test
	public void drop1(){
		boolean eCaught = false;
		String query = "create table simple1 (f1 varchar2(10), f2 varchar2(15) primary key);\n";
		String out = null;
		try{
			Main m = new Main();
			out = m.process(query);
			out = m.process("drop table simple1;\n");
			if(out == null || !out.equals("Table dropped.\n"))
				throw new Exception();
			out = m.process(query);
				
			
		}catch(Exception e){
			eCaught = true;
		}
		
		if(!eCaught && out != null && out.equals("Table created.\n")){
			score+= Breakdown.drop1;
			SC.score.append("\n\t dropTable drops tables correctly - " + Breakdown.drop1 + "/" + Breakdown.drop1);
		}else{
			SC.score.append("\n\t dropTable doesn't drop tables correctly  - 0/" + Breakdown.drop1);
		}	
	}
	
	
	
	
}
